package com.fight.strive.sys.modules.scheduler.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fight.strive.sys.modules.common.PageR;
import com.fight.strive.sys.modules.common.ReStatus;
import com.fight.strive.sys.modules.scheduler.entity.SchExecutorEntity;
import com.fight.strive.sys.modules.scheduler.service.SchExecutorService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/sys/scheduler/executor")
public class SchExecutorController {

    @Resource
    private SchExecutorService schExecutorService;

    @PostMapping("/save")
    public ReStatus<Void> save(@RequestBody SchExecutorEntity entity) {
        schExecutorService.saveE(entity);
        return ReStatus.success();
    }

    @PostMapping("/list")
    public ReStatus<IPage<SchExecutorEntity>> list(
            @RequestBody PageR<SchExecutorEntity> page) {
        return ReStatus.success(
                schExecutorService.list(page));
    }

    @PostMapping("/listAll")
    public ReStatus<List<SchExecutorEntity>> listAll() {
        return ReStatus.success(
                schExecutorService.list());
    }

    @PostMapping("/remove")
    public ReStatus<Void> remove(@RequestBody SchExecutorEntity entity) {
        schExecutorService.remove(entity);
        return ReStatus.success();
    }

    @RequestMapping("/get/{id}")
    public ReStatus<SchExecutorEntity> getExecutor(@PathVariable String id) {
        return ReStatus.success(
                schExecutorService.getById(id));
    }
}
